package com.ax.business.doctor.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ax.business.doctor.domain.BaseDoctor;
import com.ax.business.common.domain.BaseOrg;
import com.ax.business.doctor.domain.BasePharmacist;
import com.ax.business.common.service.OrgInformationService;
import com.ax.business.common.util.AjaxRes;
import com.ax.business.common.util.Const;
import com.ax.business.common.util.PageUtils;

@Controller
@ResponseBody
public class OrgInformationController {

	@Autowired
	OrgInformationService orgInformationService;
	
	
	/**
	 * 查看医生详情(模块:医生呈现，医生详情*查询某科室下面的医生)
	 * 
	 * @param BaseDoctor baseDoctor
	 *           
	 * @return PageUtils
	 */
	@RequestMapping("/queryBaseDoctor")
	public AjaxRes queryBaseDoctor(AjaxRes ajaxRes,@RequestParam Map<String, Object> params){
		try {
			PageUtils baseDoctors = orgInformationService.queryBaseDoctorSer(params);
			ajaxRes.setSucceed(baseDoctors, Const.DATA_SUCCEED);
		} catch (Exception e){
			ajaxRes.setFailMsg(e.getMessage());
		}
		return ajaxRes;
	}


	
	
	/**
	 * 查看药师详情(模块:药师，药师详情)
	 * 
	 * @param BasePharmacist basePharmacist
	 *           
	 * @return PageUtils
	 */
	@RequestMapping("/queryBasePharmacist")
	public AjaxRes queryBasePharmacist(AjaxRes ajaxRes,@RequestParam Map<String, Object> params){
		try {
			PageUtils basePharmacists = orgInformationService.queryBasePharmacistSer(params);
			ajaxRes.setSucceed(basePharmacists, Const.DATA_SUCCEED);
		} catch (Exception e){
			ajaxRes.setFailMsg(e.getMessage());
		}
		return ajaxRes;
	}
	
	/**
	 * 组织机构查询(模块:组织机构)
	 * 
	 * @param Map<String,Object> map
	 *           
	 * @return BaseOrg baseOrg
	 */
	@RequestMapping("/queryBaseOrg")
	public AjaxRes queryBaseOrg(AjaxRes ajaxRes,@RequestParam Map<String,Object> params){
		try {
			List<BaseOrg> baseOrgs = this.orgInformationService.queryBaseOrgSer(params);
			ajaxRes.setSucceed(baseOrgs,Const.DATA_SUCCEED);
		} catch (Exception e){
			ajaxRes.setFailMsg(e.getMessage());
		}
		return ajaxRes;
	}
	
	/**
	 * 组织机构新增(模块:组织机构)
	 * 
	 * @param BaseOrg baseOrg
	 *           
	 * @return SUCC
	 */
	@RequestMapping("/insertBaseOrg")
	public AjaxRes insertBaseOrg(AjaxRes ajaxRes,BaseOrg baseOrg){
		try {
			this.orgInformationService.insertBaseOrgSer(baseOrg);
			ajaxRes.setSucceed(Const.SAVE_SUCCEED);
		} catch (Exception e){
			ajaxRes.setFailMsg(e.getMessage());
		}
		return ajaxRes;
	}
	
	/**
	 * 组织机构修改(模块:组织机构)
	 * 
	 * @param BaseOrg baseOrg
	 *           
	 * @return SUCC
	 */
	@RequestMapping("/updateBaseOrg")
	public AjaxRes updateBaseOrg(AjaxRes ajaxRes,BaseOrg baseOrg){
		try {
			this.orgInformationService.updateBaseOrgSer(baseOrg);
			ajaxRes.setSucceed(Const.UPDATE_SUCCEED);
		} catch (Exception e){
			ajaxRes.setFailMsg(e.getMessage());
		}
		return ajaxRes;
	}
	
	/**
	 * 新增医生详情(模块:医生)
	 * 
	 * @param BaseDoctor baseDoctor
	 *           
	 * @return SUCC
	 */
	@RequestMapping("/insertBaseDoctor")
	public AjaxRes insertBaseDoctor(AjaxRes ajaxRes,@RequestParam Map<String,Object> params,BaseDoctor baseDoctor){
		try {
			this.orgInformationService.insertBaseDoctorSer(baseDoctor);
			ajaxRes.setSucceed(Const.SAVE_SUCCEED);
		} catch (Exception e){
			ajaxRes.setFailMsg(e.getMessage());
		}
		return ajaxRes;
	}
	
	/**
	 * 新增药师详情(模块:药师)
	 * 
	 * @param BasePharmacist basePharmacist
	 *           
	 * @return SUCC
	 */
	@RequestMapping("/insertBasePharmacist")
	public AjaxRes insertBasePharmacist(AjaxRes ajaxRes,@RequestParam Map<String,Object> params,BasePharmacist basePharmacist){
		try {
			this.orgInformationService.insertBasePharmacistSer(basePharmacist);
			ajaxRes.setSucceed(Const.SAVE_SUCCEED);
		} catch (Exception e){
			ajaxRes.setFailMsg(e.getMessage());
		}
		return ajaxRes;
	}
}

